package lianxi;

import java.time.LocalDate;
import java.util.*;

/**
 * 回文日期
 */
public class Main2 {
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        //20200202
        String year = s.substring(0,4);
        String moon = s.substring(4,6);
        String day = s.substring(6,8);
        LocalDate date = LocalDate.parse(year+"-"+moon+"-"+day);
        System.out.println(date.toString());
        date = date.plusDays(1);
        System.out.println(date.toString());
        String a=null,b=null;
        boolean flag = false;
        while(true) {
            String newdate = date.toString().replace("-","");
            if(ishuiwen(newdate) && flag == false) {
                flag = true;
                a = newdate;
            }

            if(isAB(newdate)) {
                b = newdate;
                break;
            }
            date = date.plusDays(1);
        }
        System.out.println(a);
        System.out.println(b);
        sc.close();
    }

    public static boolean ishuiwen(String date) {
        for(int i=0;i<date.length()/2;i++) {
            char ch1 = date.charAt(i);
            char ch2 = date.charAt(date.length()-i-1);
            if(ch1!=ch2) return false;
        }
        return true;
    }

    public static boolean isAB(String date) {
        char []ch = date.toCharArray();
        if( ch[0]==ch[2] && ch[2]==ch[5] && ch[5]==ch[7]&& ch[1]==ch[3]&& ch[3]==ch[4] && ch[4]==ch[6]) {
            return true;
        }
        return false;
    }
}
